package com.hdoit.kylin.web.user.modelconfig;

import com.hdoit.kylin.web.user.provider.StudentRoleProvider;
import com.hdoit.kylin.web.user.provider.TeacherProvider;
import com.tennetcn.common.enums.ManageContainer;
import com.tennetcn.common.enums.regular.RegularExpressions;
import com.tennetcn.component.attribute.DisplayNameAttribute;
import com.tennetcn.component.attribute.DropDownListAttribute;
import com.tennetcn.component.attribute.RegularExpressionAttribute;
import com.tennetcn.component.attribute.RemoteAttribute;
import com.tennetcn.component.attribute.RequiredAttribute;
import com.tennetcn.component.attribute.base.ModelMetadataAttributeConfiguration;
import com.tennetcn.web.cbase.providers.SexProvider;

public class StudentConfig extends ModelMetadataAttributeConfiguration{
	public StudentConfig(){
		this.setProperty("studentName")
			.hasAttribute(new DisplayNameAttribute("姓名"))
			.hasAttribute(new RequiredAttribute("姓名为必填项"));
		
		this.setProperty("studentId")
			.hasAttribute(new DisplayNameAttribute("学号"))
			.hasAttribute(new RequiredAttribute("学号为必填项"));
					
		RemoteAttribute RemoteAttribute=new RemoteAttribute();
		RemoteAttribute.setAdditionalfields("*.employeeId,*.employeeAccount");
		RemoteAttribute.setErrorMessage("已经存在相应的帐号");
		RemoteAttribute.setRemoteUrl(ManageContainer.VIRTUALPATH+"/admin/user/student/checkAccount");
		
		this.setProperty("roleIds")
			.hasAttribute(new DisplayNameAttribute("学生类别"))
			.hasAttribute(new RequiredAttribute())
			.hasAttribute(new DropDownListAttribute(new StudentRoleProvider(),false));
		
		this.setProperty("employeeAccount")
			.hasAttribute(new DisplayNameAttribute("帐号"))
			.hasAttribute(new RequiredAttribute("帐号为必填项"))
			.hasAttribute(RemoteAttribute);
		
		this.setProperty("teacherId")
			.hasAttribute(new DisplayNameAttribute("导师"))
			.hasAttribute(new RequiredAttribute())
			.hasAttribute(new DropDownListAttribute(new TeacherProvider(),false));
		this.setProperty("sex")
			.hasAttribute(new DisplayNameAttribute("性别"))
			.hasAttribute(new DropDownListAttribute(new SexProvider()));
		this.setProperty("mobile")
			.hasAttribute(new DisplayNameAttribute("电话"))
			.hasAttribute(new RegularExpressionAttribute(RegularExpressions.mobile));
		this.setProperty("email")
			.hasAttribute(new DisplayNameAttribute("邮箱"))
			.hasAttribute(new RegularExpressionAttribute(RegularExpressions.email));
		this.setProperty("admissionDate")
			.hasAttribute(new DisplayNameAttribute("入学时间"));
		
		this.setProperty("comments")
			.hasAttribute(new DisplayNameAttribute("备注"));

	}
}
